// 转化 px 到 rem 脚本
import fs from "fs"

let path = process.argv[2]
let data = fs.readFileSync(path, 'utf8')
let reg = /(-?\d+)px/g
let newData = data.replaceAll(/(-?375)px/g, (txt, $1) => {
  return $1.indexOf('-') === -1 ? '100%' : "-100%"
})
newData = newData.replaceAll(reg, (txt, $1) => {
  return `rem(${$1})`
})
fs.writeFileSync("./dist.vue", newData, { flag: 'w+', encoding: 'utf8' })
console.log('生成成功!');
